package maps

import "fmt"

func main() {
	m := map[string]string{
		"name": "ccmouse",
		"course": "golang",
		"site": "imooc",
		"quality": "notbad",
	}

	m2 := make(map[string]int) //m2 == empty map
	var m3 map[string]int //m3 == nil
	fmt.Println(m, m2, m3)

	fmt.Println("Traversing map")  //map的key是无序的， 是hash
	for k, v := range m {
		fmt.Println(k, v)
	}
	fmt.Println("Getting values")
	courName, ok := m["cour"] //判断一个key 存不存在
	fmt.Println(courName, ok)

	courseName, ok := m["course"]
	fmt.Println(courseName, ok)

	if cName, ok := m["c"]; ok {
		fmt.Println(cName)
	}else {
		fmt.Println("key does not exist")
	}

	fmt.Println("Deleteing values")
	name, ok := m["name"]
	fmt.Println(name, ok)
	delete(m, "name")
	name, ok = m["name"]
	fmt.Println(name, ok)

}
